package com.tencent.sr.iris.basic.mp.service;

import com.tencent.sr.iris.basic.mp.dependency.ShortUrlDependency;
import com.tencent.sr.iris.basic.mp.interfaces.request.ConvertShortUrlRequest;
import com.tencent.sr.iris.basic.mp.interfaces.response.ConvertShortUrlResponse;
import com.tencent.sr.rmall.shorturl.interfaces.vo.ShortRequest;
import com.tencent.sr.rmall.shorturl.interfaces.vo.ShortResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ShortUrlService {

    @Autowired
    private ShortUrlDependency shortUrlDependency;

    public ConvertShortUrlResponse convertShortUrl(ConvertShortUrlRequest request) {
        ShortRequest shortRequest = new ShortRequest();
        shortRequest.setTransferType(request.getTransferType().byteValue());
        shortRequest.setContent(request.getContent());
        ShortResponse shortResponse = shortUrlDependency.getShortUrl(shortRequest);

        ConvertShortUrlResponse response = new ConvertShortUrlResponse();
        response.setContent(shortResponse.getContent());
        return response;
    }
}
